<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>添加学生</title>
		<link type="text/css" rel="stylesheet" href="/layui/css/layui.css">
		<script src="/jquery/jquery-3.6.0.js"></script>
		<script src="/layuimoduls/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
	</head>
	<body>
	<form class="layui-form" lay-filter="form" id="form">
		<div class="layui-form-item">
			<label class="layui-form-label">用户名</label>
			<div class="layui-input-inline">
				<input type="text" name="username"  class="layui-input" >
			</div>
			<div class="layui-form-mid layui-word-aux" >请输入用户名</div>
		</div>

		<div class="layui-form-item">
			<label class="layui-form-label">真实姓名</label>
			<div class="layui-input-inline">
				<input type="text" name="realname"  class="layui-input" >
			</div>
			<div class="layui-form-mid layui-word-aux" >请输入学生真实姓名</div>
		</div>

		<div class="layui-form-item">
			<label class="layui-form-label">密码</label>
			<div class="layui-input-inline">
				<input type="password" id="pwd" name="password" placeholder="请输入密码"  class="layui-input">
			</div>
		</div>

		<div class="layui-form-item">
			<label class="layui-form-label">确认密码</label>
			<div class="layui-input-inline">
				<input type="password" name="password2" placeholder="请再次输入密码"  class="layui-input" id="pwd2">
			</div>
			<div class="layui-form-mid layui-word-aux" id="msg">请填写6到12位密码</div>
		</div>

		<div class="layui-form-item">
			<label class="layui-form-label">学生电话</label>
			<div class="layui-input-inline">
				<input type="text" name="serialnumber"  class="layui-input">
			</div>
			<div class="layui-form-mid layui-word-aux"></div>
		</div>

		<div class="layui-form-item">
			<label class="layui-form-label">学生邮箱</label>
			<div class="layui-input-inline">
				<input type="text" name="mailnumber"  class="layui-input" >
			</div>
			<div class="layui-form-mid layui-word-aux" ></div>
		</div>

		<div class="layui-form-item">
			<div class="layui-input-block">
				<button class="layui-btn layui-btn-disabled"  lay-submit="" lay-filter="addStudent" id="send" readonly="readonly">立即添加</button>
				<button type="reset" class="layui-btn layui-btn-primary">重置</button>
			</div>
		</div>
	</form>

	</body>
	<script>
		layui.use(['form'], function () {
			var form = layui.form;
			$('#form').click(function (e) {
				//禁用表单的默认提交事件
				e.preventDefault();
			})
			form.on('submit(addStudent)', function (data) {
				layer.alert("确定提交？");
				var arr = [];
				console.log(JSON.stringify(data))
				$.ajax({
					url:'/addStudent',
					data:JSON.stringify(data),
					type:'post',
					contentType:'application/json;charset=utf-8',
					dataType:'json',
					success:function (response) {
						if(response.success){
							layer.msg(response.msg)
							return false;
						}else{
							layer.msg(response.msg)
							return false;
						}
					}
				})
			});
		})
	</script>
</html>
